
--[[
setup script for Game2D
copy this script to your own game directory.
and call it using dofile("game2d.lua")
]]

math.randomseed(os.time())

--[[
Create entity object table.
Entities are added to this table by TEntity.SetScript()
and removed by the function TEntity.Removed()
]]
entitytable = {}


--called from TEntity.SetScript()
function EntityAdded(entity)
	this = {}
	entitytable[entity] = this
	this.id = entity:GetId()
end


--called from TEntity.Removed()
function EntityRemoved(entity)
	entitytable[entity] = nil
end

-- returns true of entity images collide
-- scale and rotation included.
function EntityCollide(entity1, entity2)
	return entity1:Collide(entity2)
end


-- bmax key codes

MOUSE_LEFT=1
MOUSE_RIGHT=2
MOUSE_MIDDLE=3

KEY_BACKSPACE=8
KEY_TAB=9
KEY_CLEAR=12
KEY_RETURN=13
KEY_ENTER=13
KEY_ESCAPE=27
KEY_SPACE=32
KEY_PAGEUP=33
KEY_PAGEDOWN=34
KEY_END=35
KEY_HOME=36

KEY_LEFT=37
KEY_UP=38
KEY_RIGHT=39
KEY_DOWN=40

KEY_SELECT=41
KEY_PRINT=42
KEY_EXECUTE=43
KEY_SCREEN=44
KEY_INSERT=45
KEY_DELETE=46

KEY_0=48
KEY_1=49
KEY_2=50
KEY_3=51
KEY_4=52
KEY_5=53
KEY_6=54
KEY_7=55
KEY_8=56
KEY_9=57
KEY_A=65
KEY_B=66
KEY_C=67
KEY_D=68
KEY_E=69
KEY_F=70
KEY_G=71
KEY_H=72
KEY_I=73
KEY_J=74
KEY_K=75
KEY_L=76
KEY_M=77
KEY_N=78
KEY_O=79
KEY_P=80
KEY_Q=81
KEY_R=82
KEY_S=83
KEY_T=84
KEY_U=85
KEY_V=86
KEY_W=87
KEY_X=88
KEY_Y=89
KEY_Z=90

KEY_NUM0=96
KEY_NUM1=97
KEY_NUM2=98
KEY_NUM3=99
KEY_NUM4=100
KEY_NUM5=101
KEY_NUM6=102
KEY_NUM7=103
KEY_NUM8=104
KEY_NUM9=105

KEY_NUMMULTIPLY=106
KEY_NUMADD=107
KEY_NUMSUBTRACT=109
KEY_NUMDECIMAL=110
KEY_NUMDIVIDE=111

KEY_F1=112
KEY_F2=113
KEY_F3=114
KEY_F4=115
KEY_F5=116
KEY_F6=117
KEY_F7=118
KEY_F8=119
KEY_F9=120
KEY_F10=121
KEY_F11=122
KEY_F12=123

KEY_TILDE=192
KEY_MINUS=189
KEY_EQUALS=187

KEY_OPENBRACKET=219
KEY_CLOSEBRACKET=221
KEY_BACKSLASH=226

KEY_SEMICOLON=186
KEY_QUOTES=222

KEY_COMMA=188
KEY_PERIOD=190
KEY_SLASH=191

KEY_LSHIFT=160
KEY_RSHIFT=161
KEY_LCONTROL=162
KEY_RCONTROL=163
KEY_LALT=164
KEY_RALT=165
KEY_LSYS=91
KEY_RSYS=92
